package com.nbsaas.boot.room.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.jpa.data.entity.LongEntity;
import com.nbsaas.boot.rest.filter.Operator;
import com.nbsaas.boot.shop.data.entity.Shop;
import lombok.Data;
import org.hibernate.annotations.Comment;

import javax.persistence.*;
import java.util.Date;

@Data
@FormAnnotation(title = "房间")
@Entity
@Table(name = "bs_shop_room")
public class Room extends LongEntity {

  public static Room fromId(Long id) {
    Room result = new Room();
    result.setId(id);
    return result;
  }

  /**
   * 场馆名称
   */
  @Comment("房间名称")
  @SearchItem(label = "房间名称", name = "name")
  @FormField(title = "房间名称",width = "200",  grid = true, col = 22)
  private String name;


  @FormField(title = "商家",width = "200",  grid = true, col = 22,type = InputType.select,option = "shop")
  @SearchItem(label = "商家", name = "shop", key = "shop.id", operator = Operator.eq, classType = Long.class )
  @Comment("商家id")
  @JoinColumn(name = "shop_id")
  @FieldConvert
  @FieldName
  @ManyToOne(fetch = FetchType.LAZY)
  private Shop shop;


  private String logo;

  private String icon;

  @Comment("地址")
  @FormField(title = "地址", width = "360",grid = true, col = 22)
  private String address;

  @Comment("联系电话")
  @FormField(title = "联系电话", width = "200",  grid = true, col = 22)
  private String phone;

  /**
   * 经度
   */
  private Float lng;

  /**
   * 地理纬度
   */
  private Float lat;

  private String note;

  /**
   * 添加时间
   */
  @FormField(title = "添加时间", grid = true, width = "10000",ignore = true)
  @Comment("添加时间")
  private Date addDate;

  /**
   * 最新修改时间
   */
  @Comment("最新修改时间")
  private Date lastDate;


}
